package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Peisongyuan;
import com.ruoyi.system.service.IPeisongyuanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配送员管理Controller
 * 
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/system/peisongyuan")
public class PeisongyuanController extends BaseController
{
    @Autowired
    private IPeisongyuanService peisongyuanService;

    /**
     * 查询配送员管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:peisongyuan:list')")
    @GetMapping("/list")
    public TableDataInfo list(Peisongyuan peisongyuan)
    {
        startPage();
        List<Peisongyuan> list = peisongyuanService.selectPeisongyuanList(peisongyuan);
        return getDataTable(list);
    }

    /**
     * 导出配送员管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:peisongyuan:export')")
    @Log(title = "配送员管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Peisongyuan peisongyuan)
    {
        List<Peisongyuan> list = peisongyuanService.selectPeisongyuanList(peisongyuan);
        ExcelUtil<Peisongyuan> util = new ExcelUtil<Peisongyuan>(Peisongyuan.class);
        util.exportExcel(response, list, "配送员管理数据");
    }

    /**
     * 获取配送员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:peisongyuan:query')")
    @GetMapping(value = "/{psyId}")
    public AjaxResult getInfo(@PathVariable("psyId") Long psyId)
    {
        return success(peisongyuanService.selectPeisongyuanByPsyId(psyId));
    }

    /**
     * 新增配送员管理
     */
    @PreAuthorize("@ss.hasPermi('system:peisongyuan:add')")
    @Log(title = "配送员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Peisongyuan peisongyuan)
    {
        return toAjax(peisongyuanService.insertPeisongyuan(peisongyuan));
    }

    /**
     * 修改配送员管理
     */
    @PreAuthorize("@ss.hasPermi('system:peisongyuan:edit')")
    @Log(title = "配送员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Peisongyuan peisongyuan)
    {
        return toAjax(peisongyuanService.updatePeisongyuan(peisongyuan));
    }

    /**
     * 删除配送员管理
     */
    @PreAuthorize("@ss.hasPermi('system:peisongyuan:remove')")
    @Log(title = "配送员管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{psyIds}")
    public AjaxResult remove(@PathVariable Long[] psyIds)
    {
        return toAjax(peisongyuanService.deletePeisongyuanByPsyIds(psyIds));
    }
}
